#include "SoundManager.h"

#ifdef PLATFORM_WINDOWS
#include <Windows.h>
#include <MMSystem.h>
#endif

char8_t* soundString[50] = 
{
	"resources/background_level1.mp3",
	"resources/drumloop.wav",
	"resources/jump1.mp3",
	"resources/dash1.mp3",
};

SoundManager* SoundManager::sInstance = NULL;

SoundManager* SoundManager::CreateInstance()
{
	if(sInstance!=NULL)return sInstance;
	else

		sInstance = new SoundManager();
	return sInstance;
}

void SoundManager::init()
{
	FMOD::System_Create(&system);
	system->init(32, FMOD_INIT_NORMAL, 0);
	
}

void SoundManager::PlayBackgoundSound(SOUND_NAME index)
{
	system->createSound(soundString[index], FMOD_HARDWARE, 0, &sound_background);
	sound_background->setMode(FMOD_LOOP_NORMAL);
	system->playSound(FMOD_CHANNEL_FREE, sound_background, false, &channel1);
}

void SoundManager::PlaySFXSound(SOUND_NAME index)
{
	if(sound_SFX[index] == NULL)
		system->createSound(soundString[index], FMOD_HARDWARE, 0, &(sound_SFX[index]));
	sound_SFX[index]->setMode(FMOD_LOOP_OFF);
 	system->playSound(FMOD_CHANNEL_FREE, sound_SFX[index], false, &channel2);
}

